import 'dart:io';

import 'package:shelf_router/shelf_router.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;

void main() async {
  var app = Router();
  app.get('/', (Request request) {
    var file = File('./lib/shelf_router/quickstart.dart');
    return Response.ok(file.readAsStringSync());
  });

  app.get('/assert/<file>', (Request request,String file) {
    return Response.ok(file);
  });

  app.get('/hello', (Request request) {
    return Response.ok('hello-world');
  });

  app.get('/user/<user>', (Request request, String user) {
    return Response.ok('hello $user');
  });

  var server = await io.serve(app, 'localhost', 8080);
  print('server start at ${server.address.host}:${server.port}');
}
